package com.koron.ticket.line.work.workticket.controller;


import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.ticket.line.work.workticket.bean.po.LineTicketOrder;
import com.koron.ticket.line.work.workticket.service.LineTicketOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 线路工作票工单信息(LineTicketOrder)表控制层
 *
 * @author jzp
 * @since 2023-02-03 16:33:13
 */
@Api(tags = "线路工作票工单信息接口")
@RestController
@RequestMapping("lineWork/ticketOrder")
public class LineTicketOrderController {
    /**
     * 服务对象
     */
    @Autowired
    private LineTicketOrderService lineTicketOrderService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping
    public Response<LineTicketOrder> selectOne(@RequestParam String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), lineTicketOrderService, "getById", LineTicketOrder.class, id));
    }

    /**
     * 通过ticketId查询
     *
     * @param ticketId 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据工作票id查询")
    @GetMapping("listByTicketId")
    public Response<List<LineTicketOrder>> listByTicketId(String ticketId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), lineTicketOrderService, "listByTicketId", List.class, ticketId));
    }

    /**
     * 批量保存
     *
     * @param lineTicketOrderList 工单内容
     */
    @ApiOperation(value = "批量保存")
    @PostMapping("saveBatch")
    public Response<String> listByTicketId(@RequestBody List<LineTicketOrder> lineTicketOrderList) {
        ADOConnection.runTask(getCurrDs(), lineTicketOrderService, "saveBatch", Boolean.class, lineTicketOrderList);
        return Response.ok();
    }


}

